package com.company.huisuo.biz.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import com.company.huisuo.base.BaseSingleAdapter
import com.company.huisuo.databinding.ItemDialogArtistTestBinding

/**
 * 艺人试台
 */
class ArtistTestDialogAdapter : BaseSingleAdapter<Any, ItemDialogArtistTestBinding>() {

    private var mSelectPos = arrayListOf(0)

    override val initViewBinding: (LayoutInflater, ViewGroup, Boolean) -> ItemDialogArtistTestBinding
        get() = ItemDialogArtistTestBinding::inflate

    override fun convert(
        holder: SingleViewHolder<ItemDialogArtistTestBinding>, position: Int, item: Any?
    ) {
        holder.binding.tvValue.isSelected = mSelectPos.contains(position)
        holder.binding.tvValue.setOnClickListener {
            if (mSelectPos.contains(position)) {
                mSelectPos.remove(position)
            } else {
                mSelectPos.add(position)
            }
            notifyItemChanged(position)
        }
    }
}